package com.neusoft.hifly.information.column.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import com.neusoft.hifly.commons.lang.LocalDateUtil;
import com.neusoft.hifly.commons.lang.StringConstants;
import com.neusoft.hifly.core.utils.GlobalConstants;
import io.swagger.annotations.ApiModelProperty;

/**
 * Title: 文章资讯服务
 * <p>
 * Description: 栏目对象
 * <p>
 * Copyright: 2019
 * <p>
 * Company: 东软汉枫
 *
 * @author lh_neu
 * @version 1.0.0
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName(value = GlobalConstants.DYNAMIC_TABLE_NAME_PREFIX + "_INFO_COLUMN")
public class ColumnObj implements Serializable {
	private static final long serialVersionUID = -158218514193134L;
	/*
	 * 文章审核策略：不走流程
	 */
	public static final String APPROVE_RULE_0 = "0";
	/*
	 * 文章审核策略：只走编审流程
	 */
	public static final String APPROVE_RULE_1 = "1";
	/*
	 * 文章审核策略：走编校审流程
	 */
	public static final String APPROVE_RULE_2 = "2";
	/*
	 * 文章审核策略：由文章录入人员自由选择
	 */
	public static final String APPROVE_RULE_3 = "3";

	// 文章默认模板
	public static final String TEMPLATE_DEF = "default";

	// 主键
	@TableId(value = "ID")
	@ApiModelProperty(value = "主键")
	private long id;
	// 逻辑ID
	@TableField(value = "LOGIC_ID")
	@ApiModelProperty(value = "逻辑ID")
	private long logicId;
	// 租户逻辑ID
	@TableField(value = "ORGAN_LOGIC_ID")
	@ApiModelProperty(value = "租户逻辑ID")
	private long organLogicId;
	// 栏目父ID（一级栏目为0）
	@TableField(value = "COLUMN_PID")
	@ApiModelProperty(value = "栏目父ID（一级栏目为0）")
	private long pid;
	// 栏目所属根ID
	@TableField(value = "COLUMN_ROOTID")
	@ApiModelProperty(value = "栏目所属根ID")
	private long rootId;
	// 栏目主键串
	@TableField(value = "COLUMN_ID_PATH")
	@ApiModelProperty(value = "栏目主键串")
	private String idPath;
	// 栏目名称
	@TableField(value = "COLUMN_NAME")
	@ApiModelProperty(value = "栏目名称")
	private String name;
	// 栏目图片
	@TableField(value = "COLUMN_IMG")
	@ApiModelProperty(value = "栏目图片")
	private String img;
	// 栏目排序
	@TableField(value = "COLUMN_ORDER")
	@ApiModelProperty(value = "栏目排序")
	private int myOrder;
	// 文章模板：默认为DEFAULT
	@TableField(value = "ART_TEMPLATE")
	@ApiModelProperty(value = "文章模板：默认为DEFAULT")
	private String artTemplate;
	// 是否同步到微网站(默认0否，1是)
	@TableField(value = "SYNC_MINI_SITE")
	@ApiModelProperty(value = "是否同步到微网站(默认0否，1是)", example = "0")
	private String syncMiniSite;
	// 是否同步到手机(默认0否，1是)
	@TableField(value = "SYNC_APP")
	@ApiModelProperty(value = "是否同步到手机(默认0否，1是)", example = "0")
	private String syncApp;
	// 评论策略,0不评论,1评论需要审核,2评论不需要审核,3由文章录入人员自由选择
	@TableField(value = "COMMENT_RULE")
	@ApiModelProperty(value = "评论策略,0不评论,1评论需要审核,2评论不需要审核,3由文章录入人员自由选择", example = "0")
	private String commentRule;
	// 文章审核策略,0不走流程,1只走编审流程,2走编校审流程,3由文章录入人员自由选择
	@TableField(value = "APPROVE_RULE")
	@ApiModelProperty(value = "文章审核策略,0不走流程,1只走编审流程,2走编校审流程,3由文章录入人员自由选择", example = "0")
	private String approveRule;
	// 允许录入人员自由选择关联栏目,1允许,0不允许
	@TableField(value = "COLUMN_RULE")
	@ApiModelProperty(value = "允许录入人员自由选择关联栏目,1允许,0不允许", example = "0")
	private String columnRule;
	// 备注
	@TableField(value = "COLUMN_MEMO")
	@ApiModelProperty(value = "备注")
	private String memo;
	// 修改人
	@TableField(value = "UPDATE_PERSON")
	@ApiModelProperty(value = "修改人")
	private String updatePerson;
	// 修改时间
	@TableField(value = "UPDATE_TIME")
	@ApiModelProperty(value = "修改时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	private LocalDateTime updateTime;
	// 扩展字段1
	@TableField(value = "EXT1")
	private String ext1;
	// 扩展字段2
	@TableField(value = "EXT2")
	private String ext2;
	// 扩展字段3
	@TableField(value = "EXT3")
	private String ext3;
	// 扩展字段4
	@TableField(value = "EXT4")
	private String ext4;
	// 扩展字段5
	@TableField(value = "EXT5")
	private String ext5;

	// ################### 临时数据 ####################

	// 格式化后的字符串日期
	@TableField(exist = false)
	private String updateTimeStr;
	// 依据该策略重置子栏目策略(默认0否，1是)
	@TableField(exist = false)
	private String isResetSub;
	// 租户
	@TableField(exist = false)
	private String organCode;

	/**
	 * 得到对象的哈希值
	 *
	 * @return int 对象的哈希值
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.getLogicId()).toHashCode();
	}

	/**
	 * 比较两个对象是否相等
	 *
	 * @param other
	 *            要比较的对象
	 * @return boolean 相同返回true，否则返回flase
	 */
	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof ColumnObj)) {
			return false;
		}
		final ColumnObj castOther = (ColumnObj) other;
		return new EqualsBuilder().append(this.getLogicId(), castOther.getLogicId()).isEquals();
	}

	/**
	 * 返回对象的字符串值
	 *
	 * @return String 表示用户对象的字符串值
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("栏目", this.getName()).toString();
	}

	/**
	 * 将DATE类型的时间格式化为字符串类型
	 *
	 * @return 字符串时间
	 */
	public String getUpdateTimeStr() {
		if (this.updateTime != null) {
			this.updateTimeStr = LocalDateUtil.showTime(this.updateTime);
		}
		return this.updateTimeStr;
	}

	/**
	 * 是否同步到微网站
	 *
	 * @return 是否同步到微网站
	 */
	public String getSyncMiniSite() {
		if (StringUtils.isEmpty(syncMiniSite)) {
			this.syncMiniSite = StringConstants.NO;
		}
		return syncMiniSite;
	}

	/**
	 * 是否同步到手机
	 *
	 * @return 是否同步到手机
	 */
	public String getSyncApp() {
		if (StringUtils.isEmpty(syncApp)) {
			this.syncApp = StringConstants.NO;
		}
		return syncApp;
	}

	/**
	 * 评论策略
	 *
	 * @return 评论策略
	 */
	public String getCommentRule() {
		if (StringUtils.isEmpty(commentRule)) {
			this.commentRule = StringConstants.NO;
		}
		return commentRule;
	}

	/**
	 * 文章审核策略
	 *
	 * @return 文章审核策略
	 */
	public String getApproveRule() {
		if (StringUtils.isEmpty(approveRule)) {
			this.approveRule = StringConstants.NO;
		}
		return approveRule;
	}

	/**
	 * 允许录入人员自由选择关联栏目
	 *
	 * @return 允许录入人员自由选择关联栏目
	 */
	public String getColumnRule() {
		if (StringUtils.isEmpty(columnRule)) {
			this.columnRule = StringConstants.NO;
		}
		return columnRule;
	}

	/**
	 * 文章模板
	 *
	 * @return 文章模板
	 */
	public String getArtTemplate() {
		if (StringUtils.isEmpty(artTemplate)) {
			artTemplate = ColumnObj.TEMPLATE_DEF;
		}
		return artTemplate;
	}

	public long getId() {
		return id;
	}

	public void setId(final long id) {
		this.id = id;
	}

	public long getLogicId() {
		return logicId;
	}

	public void setLogicId(final long logicId) {
		this.logicId = logicId;
	}

	public long getOrganLogicId() {
		return organLogicId;
	}

	public void setOrganLogicId(final long organLogicId) {
		this.organLogicId = organLogicId;
	}

	public long getPid() {
		return pid;
	}

	public void setPid(final long pid) {
		this.pid = pid;
	}

	public long getRootId() {
		return rootId;
	}

	public void setRootId(final long rootId) {
		this.rootId = rootId;
	}

	public String getIdPath() {
		return idPath;
	}

	public void setIdPath(final String idPath) {
		this.idPath = idPath;
	}

	public String getName() {
		return name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	public String getImg() {
		return img;
	}

	public void setImg(final String img) {
		this.img = img;
	}

	public int getMyOrder() {
		return myOrder;
	}

	public void setMyOrder(final int myOrder) {
		this.myOrder = myOrder;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(final String memo) {
		this.memo = memo;
	}

	public String getUpdatePerson() {
		return updatePerson;
	}

	public void setUpdatePerson(final String updatePerson) {
		this.updatePerson = updatePerson;
	}

	public LocalDateTime getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(final LocalDateTime updateTime) {
		this.updateTime = updateTime;
	}

	public String getExt1() {
		return ext1;
	}

	public void setExt1(final String ext1) {
		this.ext1 = ext1;
	}

	public String getExt2() {
		return ext2;
	}

	public void setExt2(final String ext2) {
		this.ext2 = ext2;
	}

	public String getExt3() {
		return ext3;
	}

	public void setExt3(final String ext3) {
		this.ext3 = ext3;
	}

	public String getExt4() {
		return ext4;
	}

	public void setExt4(final String ext4) {
		this.ext4 = ext4;
	}

	public String getExt5() {
		return ext5;
	}

	public void setExt5(final String ext5) {
		this.ext5 = ext5;
	}

	public String getIsResetSub() {
		return isResetSub;
	}

	public void setIsResetSub(final String isResetSub) {
		this.isResetSub = isResetSub;
	}

	public String getOrganCode() {
		return organCode;
	}

	public void setOrganCode(final String organCode) {
		this.organCode = organCode;
	}

	public void setArtTemplate(final String artTemplate) {
		this.artTemplate = artTemplate;
	}

	public void setSyncMiniSite(final String syncMiniSite) {
		this.syncMiniSite = syncMiniSite;
	}

	public void setSyncApp(final String syncApp) {
		this.syncApp = syncApp;
	}

	public void setCommentRule(final String commentRule) {
		this.commentRule = commentRule;
	}

	public void setApproveRule(final String approveRule) {
		this.approveRule = approveRule;
	}

	public void setColumnRule(final String columnRule) {
		this.columnRule = columnRule;
	}

	public void setUpdateTimeStr(final String updateTimeStr) {
		this.updateTimeStr = updateTimeStr;
	}
}